// pages/mall/index.ts
Page({

    /**
     * 页面的初始数据
     */
    data: {
        activeKey: 0,
        tipsList: <any>[],
        activeTipId: '',
        siderbarHeight: '',
        bottomLift: getApp().globalData.bottomLift, // 底部tabbar距离
        scrollHeight: '',
        projectList: <any>[],
        tips: <any>[],
        selectedTipId: '',   //右侧选中的tipid，默认为空，即为全部
        show: false,  //展示右侧弹窗
        checkNow: '', //右侧分类导航的第一个
        scrollTop: 0,
        tipScrollLeft: 0,  //tip滚动
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad() {
        this.getTipsList()
        this.getProjectList()
    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {
        // 自定义tabbar
        if (typeof this.getTabBar === 'function' &&
            this.getTabBar()) {
            this.getTabBar().setData({
                selected: 1
            })
        }
        this.adaptation()
    },
    // 适配高度
    adaptation() {
        const that = this;
        setTimeout(function () {
            var query = wx.createSelectorQuery();
            query.select('.topTitle').boundingClientRect();
            query.select('.topSearch').boundingClientRect();
            // query.select('.cntScroll').boundingClientRect();
            query.exec(function (rect) {
                if (rect[0] === null) return;
                let num = 0;
                rect.forEach(element => {
                    if (element != null) {
                        num += element.height
                    }
                });

                that.setData({
                    // 标题 + 搜索框 + 滑动栏 + 底部栏  + 适配距离
                    custom: num + that.data.bottomLift,  //右侧栏
                    siderbarHeight: `calc(100vh - ${rect[0].height + rect[1].height + that.data.bottomLift}px)`, //左侧栏
                })
            });
        }, 500)
    },
    // 获取分类列表
    getTipsList() {
        let list = [{ id: "62d4b478f639dd76a3641dd5", n: "血液检测" }, { id: "62d4b45bf639dd76a3641dd3", n: "常用检测" }, { id: "62d4b45bf639dd76a3641dd3", n: "常用检测" }, { id: "62d4b45bf639dd76a3641dd3", n: "常用检测" }, { id: "62d4b45bf639dd76a3641dd3", n: "常用检测" }, { id: "62d4b45bf639dd76a3641dd3", n: "常用检测" }, { id: "62d4b45bf639dd76a3641dd3", n: "常用检测" }, { id: "62d4b45bf639dd76a3641dd3", n: "常用检测" }, { id: "62d4b45bf639dd76a3641dd3", n: "常用检测" }, { id: "62d4b45bf639dd76a3641dd3", n: "常用检测" }, { id: "62d4b45bf639dd76a3641dd3", n: "常用检测" }, { id: "62d4b45bf639dd76a3641dd3", n: "常用检测" }, { id: "62d4b45bf639dd76a3641dd3", n: "常用检测" }, { id: "62d4b45bf639dd76a3641dd3", n: "常用检测" }, { id: "62d4b45bf639dd76a3641dd3", n: "常用检测" }]
        list.unshift({ id: '', n: '收藏' })
        this.setData({
            tipsList: list
        })
    },
    // 切换左侧分类
    changeTip(e: any) {
        // console.log("执行了changeTip")
        let id = e.currentTarget.dataset.id
        this.setData({
            activeTipId: id,
            checkNow: 'D ',  //右侧导航重置为全部
            selectedTipId: '',
            scrollTop: 0, // 右侧项目列表滚动到顶部
            tipScrollLeft: 0
        })

        if (id != '') {
            // 获取项目列表

        } else {
            // 获取收藏列表
        }
    },
    scroll(e) {
        // console.log(e)
    },
    getProjectList() {
        let tips = [
            {
                "id": "62d4b5d2f639dd76a3641de8",
                "n": "MPN检测"
            },
            {
                "id": "62d4b5c7f639dd76a3641de7",
                "n": "MM检测"
            },
            {
                "id": "62d4b5bdf639dd76a3641de6",
                "n": "MDS检测"
            },
            {
                "id": "62d4b5aff639dd76a3641de5",
                "n": "CLL检测"
            },
            {
                "id": "62d4b5a8f639dd76a3641de4",
                "n": "AML检测"
            },
            {
                "id": "62d4b59ef639dd76a3641de3",
                "n": "ALL检测"
            },
            {
                "id": "62d4b595f639dd76a3641de2",
                "n": "遗传性疾病检测"
            },
            {
                "id": "62d4b58af639dd76a3641de1",
                "n": "血栓性疾病检测"
            },
            {
                "id": "62d4b56ff639dd76a3641de0",
                "n": "细胞形态学检测"
            },
            {
                "id": "62d4b564f639dd76a3641ddf",
                "n": "贫血类检测"
            },
            {
                "id": "62d4b55af639dd76a3641dde",
                "n": "免疫功能检测"
            },
            {
                "id": "62d4b54ff639dd76a3641ddd",
                "n": "流式检测"
            },
            {
                "id": "62d4b518f639dd76a3641ddc",
                "n": "淋巴瘤检测"
            },
            {
                "id": "62d4b50cf639dd76a3641ddb",
                "n": "血液检验项目指南"
            },
            {
                "id": "62d4b4fff639dd76a3641dda",
                "n": "分子生物学检测"
            },
            {
                "id": "62d4b4e3f639dd76a3641dd9",
                "n": "骨髓移植配型检测"
            },
            {
                "id": "62d4b4d5f639dd76a3641dd8",
                "n": "骨髓病理检测"
            },
            {
                "id": "62d4b4bef639dd76a3641dd7",
                "n": "病原体感染检测"
            },
            {
                "id": "62d4b4a6f639dd76a3641dd6",
                "n": "融合基因类"
            }
        ];
        tips.unshift({ id: '', n: "全部" })
        this.setData({
            tips,
            projectList: [
                {
                    "id": "6316fb8985d9ec14f4824abe",
                    "tp": 1,
                    "sf": 1,
                    "n": "测试项目3",
                    "cd": "D00417",
                    "pr": "0.01",
                    "clt": 0,
                    "sp": "外周血或骨髓，紫头管2-3ml，低于4摄氏度运存",
                    "rt": "工作日，3-5天出报告",
                    "ct": "2022-09-06 15:49:29"
                },
                {
                    "id": "6316fb5985d9ec14f4824abd",
                    "tp": 1,
                    "sf": 1,
                    "n": "测试项目2",
                    "cd": "D00416",
                    "pr": "0.01",
                    "clt": 0,
                    "sp": "外周血或骨髓，紫头管2-3ml，低于4摄氏度运存",
                    "rt": "自然日时间，3-7天内出报告",
                    "ct": "2022-09-06 15:48:41"
                },
                {
                    "id": "62f5c7261825bd57193f3c19",
                    "tp": 1,
                    "sf": 1,
                    "n": "测试项目1",
                    "cd": "D00415",
                    "pr": "0.01",
                    "clt": 0,
                    "sp": "外周血或骨髓，紫头管2-3ml，低于4摄氏度运存",
                    "rt": "根据工作日5-14日，出报告结果",
                    "ct": "2022-08-12 11:21:10"
                },
                {
                    "id": "62d4c786f639dd76a3641df0",
                    "tp": 2,
                    "sf": 1,
                    "n": "MDS 男性遗传学套餐",
                    "cd": "FZ0076",
                    "pr": "4900",
                    "clt": 0,
                    "sp": "骨髓3ml，肝素抗凝（绿头管），4℃，24h送检注意事项：请务必尽填写申请单，并附近期染色体报告结果",
                    "rt": "周一至周五，5-7个工作日",
                    "ct": "2022-07-18 10:37:58"
                },
                {
                    "id": "62d4c734f639dd76a3641def",
                    "tp": 2,
                    "sf": 1,
                    "n": "MDS 女性遗传学套餐",
                    "cd": "FZ0075",
                    "pr": "4000",
                    "clt": 0,
                    "sp": "骨髓3ml，肝素抗凝（绿头管），4℃，24h送检注意事项：请务必尽填写申请单，并附近期染色体报告结果",
                    "rt": "周一至周五，5-7个工作日",
                    "ct": "2022-07-18 10:36:36"
                },
                {
                    "id": "62d4c689f639dd76a3641dee",
                    "tp": 2,
                    "sf": 1,
                    "n": "ALL预后套餐A",
                    "cd": "FZ0088",
                    "pr": "3200",
                    "clt": 0,
                    "sp": "1管肝素抗凝（绿头管）骨髓3ml（确保外周血原始幼稚细胞比例>30%）",
                    "rt": "周一至周五，7-15个工作日",
                    "ct": "2022-07-18 10:33:45"
                },
                {
                    "id": "62d4c00ab986a65f8abaaa7c",
                    "tp": 1,
                    "sf": 1,
                    "n": "BCR/ABL1（P210，P230）定性",
                    "cd": "AZ0333",
                    "pr": "300",
                    "clt": 0,
                    "sp": "骨髓2-3ml或外周血3-5ml，EDTA抗凝（紫头管）",
                    "rt": "周一至周五， 5个工作日",
                    "ct": "2022-07-18 10:06:02"
                },
                {
                    "id": "62d4c009b986a65f8abaaa7b",
                    "tp": 1,
                    "sf": 1,
                    "n": "BCR/ABL1 融合基因断裂重组位点检测",
                    "cd": "WZ000515",
                    "pr": "500",
                    "clt": 0,
                    "sp": "骨髓2-3ml或外周血3-5ml，EDTA抗凝（紫头管）",
                    "rt": "周一至周五， 5个工作日",
                    "ct": "2022-07-18 10:06:01"
                },
                {
                    "id": "62d4c007b986a65f8abaaa7a",
                    "tp": 1,
                    "sf": 1,
                    "n": "BCR/ABL1 融合基因罕见型筛查",
                    "cd": "AZ0388",
                    "pr": "400",
                    "clt": 0,
                    "sp": "骨髓2-3ml或外周血3-5ml，EDTA抗凝（紫头管）",
                    "rt": "周一至周五， 5个工作日",
                    "ct": "2022-07-18 10:05:59"
                },
                {
                    "id": "62d4c006b986a65f8abaaa79",
                    "tp": 1,
                    "sf": 1,
                    "n": "PCM1/JAK2融合基因定性",
                    "cd": "AZ0565",
                    "pr": "300",
                    "clt": 0,
                    "sp": "骨髓2-3ml或外周血3-5ml，EDTA抗凝（紫头管）",
                    "rt": "周一至周五， 5个工作日",
                    "ct": "2022-07-18 10:05:58"
                },
                {
                    "id": "62d4c005b986a65f8abaaa78",
                    "tp": 1,
                    "sf": 1,
                    "n": "BCR/ABL1 P210融合基因高灵敏度定量",
                    "cd": "AZ0725",
                    "pr": "900",
                    "clt": 0,
                    "sp": "1.初诊病人可选择骨髓2-3ml或外周血3-5ml，若检测复发和微小病灶残留，可根据初诊时检测所用标本类型，选择相应的标本类型进行检测 2.EDTA抗凝",
                    "rt": "周一至周五， 5个工作日",
                    "ct": "2022-07-18 10:05:57"
                },
                {
                    "id": "62d4c003b986a65f8abaaa77",
                    "tp": 1,
                    "sf": 1,
                    "n": "EVI1 基因定性",
                    "cd": "AZ0342",
                    "pr": "300",
                    "clt": 0,
                    "sp": "骨髓2-3ml或外周血3-5ml，EDTA抗凝（紫头管）",
                    "rt": "周一至周五， 5个工作日",
                    "ct": "2022-07-18 10:05:55"
                },
                {
                    "id": "62d4c002b986a65f8abaaa76",
                    "tp": 1,
                    "sf": 1,
                    "n": "ETV6/PDGFRB融合基因定性",
                    "cd": "AZ0341",
                    "pr": "300",
                    "clt": 0,
                    "sp": "初诊时：骨髓2-3ml或外周血3-5ml；复发或微小残留检测时必须选择骨髓2-3ml；EDTA抗凝，务必详细填写申请单",
                    "rt": "周一至周五， 5个工作日",
                    "ct": "2022-07-18 10:05:54"
                },
                {
                    "id": "62d4c000b986a65f8abaaa75",
                    "tp": 1,
                    "sf": 1,
                    "n": "EVI1 基因定量",
                    "cd": "AZ0300",
                    "pr": "500",
                    "clt": 0,
                    "sp": "初诊时：骨髓2-3ml或外周血3-5ml；复发或微小残留检测时必须选择骨髓2-3ml；EDTA抗凝，务必详细填写申请单",
                    "rt": "周一至周五， 5个工作日",
                    "ct": "2022-07-18 10:05:53"
                },
                {
                    "id": "62d4bfffb986a65f8abaaa74",
                    "tp": 1,
                    "sf": 1,
                    "n": "MPL 基因W515L/K突变定量",
                    "cd": "AZ0304",
                    "pr": "900",
                    "clt": 0,
                    "sp": "初诊时：骨髓2-3ml或外周血3-5ml；复发或微小残留检测时必须选择骨髓2-3ml；EDTA抗凝，务必详细填写申请单",
                    "rt": "周一至周五， 5个工作日",
                    "ct": "2022-07-18 10:05:51"
                }
            ],
        })
    },
    // 点击tip
    clickTip(e: any) {
        let id = e.currentTarget.dataset.id
        let index = e.currentTarget.dataset.index
        this.setData({
            selectedTipId: id,
            checkNow: 'D' + e.currentTarget.dataset.id
        })
        this.setData({ show: false });
    },
    // 更多tip
    moreTip() {
        this.setData({
            show: true
        })
    },
    // 关闭弹框
    onClose() {
        this.setData({ show: false });
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})